<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
    #dv{
        position: absolute;
        width: 800px;
        height: 600px;
        background-color: #ccc;
        top:100px;
        left:100px;
    }
    </style>
</head>
<body>
    <input type="button" value="弹出球" id="btn">
    <div id="dv">

    </div>
    <script>
        var dv=document.getElementById('dv');
    document.getElementById('btn').onclick=function(){
        var ball = document.createElement("div");
        ball.style.cssText="position:absolute; border-radius:50%;";
        ball.style.width="50px";
        ball.style.height="50px";
        ball.style.backgroundColor="red";
        dv.appendChild(ball);
        ball.style.left="375px";
        ball.style.top="275px";
        var x=10;
        var y=10;
        setInterval(function(){
            ball.style.left+=x+"px";
            ball.style.top+=y+'px';
        },30)
    };
    </script>
</body>
</html>